$(function() {
	$('.myTbl>tbody>tr:even').css('background-color', '#eee');
	$('tr:odd', $('.myTbl>tbody')).css('background-color', '#DADADA');

	var tmp = 0;
	$('.myTbl').find('tr').hover(function() {
		tmp = $(this).css('background-color');
		$(this).css('background-color', '#ddeedd');
	}, function() {
		$(this).css('background-color', tmp);
	});
});

function checkNameAanPassword() {
	var nameTxt = document.getElementById("name");
	var pwdTxt = document.getElementById("password");
	if ((!(nameTxt.value != null && nameTxt.value != ""))
			|| (!(pwdTxt.value != null && pwdTxt.value != ""))) {
		alert("用户名密码不能为空");
		return false;
	}
	return true;

}
function chkOp(id) {
	if (!(/^[1-9]\d{0,9}$/.test(id))) {
		alert("ID只能是正整数，且不能太长");
	}
}

function chkName(name) {
	$.ajax({
		url : name + '/checkName',
		type : 'post',
		data : 't=' + Math.random(),
		success : function(msg) {
			if (msg == 1) {
				$("#err").html("用户已存在");
			} else {
				$("#err").html("*");
			}
		}
	});
}

function add() {
	fun("add", "add");
}
function update(operator_id) {
	fun(operator_id + "/update", "update");
}
function del(operator_id) {
	if (window.confirm("真的在删除：" + operator_id)) {
		window.location.href = operator_id + "/del";
	}
}

function fun(url, title) {
	var w = window.screen.width;
	var h = window.screen.height;
	var ww = 360;
	var wh = 260;
	var left = (w - ww) / 2;
	var top = (h - wh) / 2;
	window
			.open(
					url,
					title,
					"width="
							+ ww
							+ ",height="
							+ wh
							+ ",left="
							+ left
							+ ",top="
							+ top
							+ ", toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no");
}
